<?php

class Form_RuleAdd extends QForm
{
    function __construct($action)
    {
        // 调用父类的构造函数
        parent::__construct('Form_RuleAdd', $action);

        // 从配置文件载入表单
        $filename = rtrim(dirname(__FILE__), '/\\') . DS . 'ruleadd_form.yaml';
        $this->loadFromConfig(Helper_YAML::loadCached($filename));

		// 为 group_id 元素设置可用的值，该元素的 _ui 是 dropdownlist
        //$parent_id_items = Hostgroup::find()->getAll()->toHashMap('id', 'groupname');
        //$parent_id_items['0'] = '请选择上级组';
        //ksort($parent_id_items);
        //$this['parent_id']->items = $parent_id_items;
        //$this['parent_id']->items = array('1'=>'管理组','2'=>'编辑组','3'=>'正常组','4'=>'其他组');

        // 添加一个隐藏字段到表单
        //$this->add(QForm::ELEMENT, 'group_id', array('_ui' => 'hidden'));
		$this->add(QForm::ELEMENT, 'datetime', array('_ui' => 'hidden','_label'=>'时间','_req'=>true,'value'=>date("Y-m-d G:i:s")));

		$this['logtypeid']->items = array(''=>'请选择日志类型');
		$this['cncategoryid']->items = array(''=>'请选择规则类型');

		// 添加一个隐藏字段到表单
        $this->add(QForm::ELEMENT, 'user_id', array('_ui' => 'hidden'));

		$parent_id_items = Hostgroup::find()
            //->order('name ASC')
            ->getAll()
            ->toHashMap('id', 'groupname');
        $parent_id_items['0'] = '请选择主机组';
        ksort($parent_id_items);
        $this['groupid']->items = $parent_id_items;

		$this['ruleflag']->items = array('0'=>'过滤','1'=>'报警');

		$this['cncategorysec']->items = array(''=>'请选择','审计成功'=>'审计成功','审计失败'=>'审计失败');
		
		$this['cnsource']->items = array(''=>'请选择','Security'=>'Security','Service Control Mana'=>'SCM');

		$this['cnid']->items = array(''=>'请选择','593'=>'593','7035'=>'7035');
		
		//$logTypeid['0'] = '请选择日志类型';
		//echo date("Y-m-d G:i:s")
        //定义表单名称
        $this->_subject = '添加新规则';

		
    }
}


?>
